package com.yuxinmuyu.sports_management.controller.publicController;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.yuxinmuyu.sports_management.bean.entiy.STeacher;
import com.yuxinmuyu.sports_management.bean.request.SelectTeacherRequest;
import com.yuxinmuyu.sports_management.bean.request.TeacherIDRequest;
import com.yuxinmuyu.sports_management.bean.response.STeacherResponse;
import com.yuxinmuyu.sports_management.exception.R;
import com.yuxinmuyu.sports_management.service.STeacherService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
@RequestMapping("/teacher")
@Api(value = "教师管理", tags = {"教师管理"})
public class STeacherController {
    @Resource
    private STeacherService sTeacherService;

    @ApiOperation("查询老师信息")
    @PostMapping("/adm/selectTeachers")
    public R<Page<STeacherResponse>> selectTeachers(@RequestBody @Validated SelectTeacherRequest request) {
        return R.success(sTeacherService.selectTeachers(request));
    }

    @ApiOperation("根据老师ID删除老师信息")
    @PostMapping("/adm/deleteTeacher")
    public R<?>deleteTeacher(@RequestBody @Validated TeacherIDRequest request){
        sTeacherService.deleteTeacher(request);
        return R.success("删除成功！");
    }

    @ApiOperation("添加老师信息")
    @PostMapping("/adm/addTeacher")
    public R<?>addTeacher(@RequestBody @Validated STeacher Teacher){
        sTeacherService.addTeacher(Teacher);
        return R.success("添加成功！");
    }

    @ApiOperation("修改老师信息")
    @PostMapping("/adm/updateTeacher")
    public R<?>updateTeacher(@RequestBody @Validated STeacher Teacher){
        sTeacherService.updateTeacher(Teacher);
        return  R.success("修改成功！");
    }

}
